#include<bits/stdc++.h>
using namespace std;
int L,n,m,V,T,ans1,ans2;
int p[100005];
struct k{
    int d,v,a;
    long long maxt;
    long double maxd;
};
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    k A[100005];
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        for(int i=0;i<n;i++){
            cin>>A[i].d>>A[i].v>>A[i].a;
            if(A[i].a<0){
                A[i].maxt=A[i].v/(0-A[i].a);
                A[i].maxd=A[i].d+A[i].v*A[i].maxt+0.5*A[i].a*A[i].maxt*A[i].maxt;
            }
        }
        for(int i=0;i<m;i++){
            cin>>p[i];
        }
        long long aaa;
        for(int j=0;j<n;j++){
            for(int i=0;i<m;i++){
                aaa=sqrt(A[j].v*A[j].v+2*A[j].a*(p[i]-A[j].d));
                if(aaa>V){
                    ans1++;
                    ans2=m-1;
                    break;
                }
            }
        }
        cout<<ans1<<" "<<ans2<<'\n';
        ans1=0;
        ans2=0;



    }


    return 0;
}

